package com.team.app.util;

import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class ConvertUtil {
	
	public static boolean isEqual(Object obj1,Object obj2){		
		if(obj1 != null){
			return obj1.equals(obj2);
		}
		if(obj2 != null){
			return obj2.equals(obj1);
		}
		return (obj1 == obj2);
	}
	
	public static boolean isEmplty(String str){
		return ("".equals(str) | str==null);
	}
	
	public static Integer toInteger(String str){
		if(!isEmplty(str) && str != null){
			return	Integer.parseInt(str);
		}
		return null;
	}
	
	public static Double toDouble(String str){
		if(!isEmplty(str) && str != null){
			return	Double.parseDouble(str);
		}
		return null;
	}
	public static Long toLong(String str){
		if(!isEmplty(str) && str != null){
			return	Long.parseLong(str);
		}
		return null;
	}
	
	public static boolean isNull(Object obj){
		return (obj == null);
	}
	
	public static String md5Hash(String input) {
        String md5 = "";
        if(null == input)
            return null;
             
        try {
            MessageDigest digest = MessageDigest.getInstance("MD5");
            digest.update(input.getBytes(), 0, input.length());
            md5 = new BigInteger(1, digest.digest()).toString(16);
  
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return md5;
    }

}
